<%@ page language="java" pageEncoding="UTF-8" buffer="16kb"%>
<%@ include file="/base.jsp"%>
<%@ include file="/module/taglibs.jsp"%>
<%@ include file="/module/nocache.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<%@ include file="/module/js.jsp"%>
<%@ include file="/module/orderField.jsp"%>
<script type="text/javascript" src="${basePath}/js/jquery.Huploadify.js"></script>
<link href="${basePath}/css/Huploadify.css" rel="stylesheet">
	<style>
table label.error {
	margin-left: 5px;
	width: auto;
	display: inline;
	color: red;
}
</style>
</head>
<body>
	<form action="#" name="Form" id="Form" method="post">
		<input type="hidden" name="zSID" id="zSID" value="${zSID}" />
		<input  type="hidden" name="dYID" id="dYID" value="${dYID}"/>
		<input  type="hidden" name="gH" id="gH" value="${gH}"/>
		<table cellpadding="0" cellspacing="0" border="0" class="table-border"
			width="80%">
			<tr>
				<td class="table-header" colspan="4">党员个人先锋指数</td>
			</tr>
			<tr>
				<td class="table-titleTD">评定学期:</td>
				<td class="table-contentTD">
					<select id="semId" name="semId" class="selectList"> 
						<option value="">全部</option>
						<c:forEach items="${semesterList}" var="semester">
							<option value="${semester.xqid}">${semester.xqmc}</option>
						</c:forEach>
					</select>
					<script>
                        compareListValue(document.getElementById("semId"),'${semester.xqid}');
					</script>
				</td>
				<td class="table-titleTD" >总分:</td>
				<td class="table-contentTD" id="score"></td>
			</tr> 
		</table>
		<br/>
		 <table class="grid" id="tb_dy_id"  width="80%">
                 <thead id="evaTr">
                 </thead>
           </table>
			<br />
			
		<table cellpadding="1" cellspacing="1" border="0" align="left">
			<tr>
				<!-- <td><input type="text" id="btnedit" class="inputButton"
					style="text-align: center;" value="编辑"/></td> -->
				<td><input type="button" id="returnBut" class="inputButton"
					value="返回" style="text-align: center;" /></td>
			</tr>
		</table>
	</form>
	<script>
			$(document).ready(function() {
				score();
				$("#semId").click(function(){
					score();
				});
				var _form=$("#Form").validate();   
				/* 编辑 */
				$("#btnedit").click(function() {
					console.log(_form)
					if(_form.form()){
						document.Form.action ="${basePath}/dyxfzs/edit";
						document.Form.submit();
						//validataSave();
					}
				});
				
				/* 返回 */
				$("#returnBut").click(function() {
		 			   window.location.href='${basePath}/dyxfzs/list';
		 		});
				/*  取消 */
				
			});
			
			   if("${msg}"!=""){
			       layer.alert("${msg}", {icon: 6});
			  } 
			/* 选择 */
		   function showdiv() {
				$('#div1').dialog('open');
			} 
		   if("${msg}"!=""){
		       layer.alert("${msg}", {icon: 6});
		  }
		   
		   function score(){
			   var zSID = $("#zSID").val();
				var semId = $("#semId").val();
				var dYID = $('#dYID').val();
				var gH = $('#gH').val();
				$.ajax({
				    url:"${basePath}/dyxfzs/getItemScore",
				    type:"post",
				    dataType:"json",
				    data:{"zSID":zSID, "semId":semId,"dYID":dYID,"gH":gH},
				    success:function(data){
				      //  alert(data);
				        
				        var dataObj = data, //返回的data为json格式的数据
				        evaTr = "<tr><td class='table-header' colspan='4'>评分</td></tr>";
				        evaTr += "<tr><td class='table-titleTD' style='font-style: normal;' >序号</td>";
				        evaTr += "<td class='table-titleTD' style='width: auto;' >项目</td>";
				        evaTr += "<td class='table-titleTD' style='width: auto;' >分值</td>";
				        evaTr += "<td class='table-titleTD' style='width: auto;' >得分</td></tr>";
                       $.each(dataObj, function(index, item){
                       	evaTr += "<tr id='evaTr'><td class='table-contentTD'>"+item.itemId+"</td>";
                       	evaTr += "<td class='table-contentTD'>"+item.itemName+"</td>";
                       	evaTr += "<td class='table-contentTD'>"+item.itemScore+"</td>";
                       	evaTr += "<td class='table-contentTD'>"+item.score+"</td></tr>";
                       	score += item.score;
                        });
                       //alert(data[0].score);
                       var score = 0.0;
                       for(var i = 0; i < data.length; i++) {
                       	score += data[i].score;
                       }
                       console.log(data);
                       console.log(evaTr);    //可以在控制台打印一下看看，这是拼起来的标签和数据
                        $("#evaTr").html(evaTr); //把内容入到这个div中即完成
                        $('#score').html(score);
				    }
				})
		   }
		</script>
</body>
</html>
